package top.caoayu.codewars;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Sum {
    public static int getSum(int a, int b) {
        return IntStream.rangeClosed(Math.min(a, b), Math.max(a, b)).sum();
    }

    public static String bmi(double weight, double height) {
        double bmi = weight / (height * height);
        if (bmi < 18.5) {
            return "Underweight";
        }
        if (bmi < 25) {
            return "Normal";
        }
        if (bmi < 30) {
            return "Overweight";
        }
        return "Obese";
    }

    public static String abbrevName(String name) {
        String[] names = name.split(" ");
        String first = names[0];
        String last = names[1];
        return first.toUpperCase().charAt(0) + "." + last.toUpperCase().charAt(0);
    }

    public static int[] map(int[] arr) {
        return Arrays.stream(arr).map(e -> e * 2).toArray();
    }

    public static String smash(String... words) {
        return String.join(" ", words).trim();
        // TODO Write your code below this comment please
    }
    public static int stringToNumber(String str) {
        //TODO: Convert str into a number
        return Integer.valueOf(str).intValue();
    }
    public static String[] stringToArray(String s) {
        //your code;
        return s.split(" ");
    }
    public int Liters(double time)  {

        //Your code goes here! Hint: You should change that -1
        return Long.valueOf(Math.floorDiv(Double.valueOf(time).longValue(),2L)).intValue();

    }
    public static List<Object> filterList(final List<Object> list) {
        // Return the List with the Strings filtered out
        System.out.println("s".getClass().getSimpleName());
        return list.stream().filter(s -> !"string".equalsIgnoreCase(s.getClass().getSimpleName())).collect(Collectors.toList());
    }
    public static int paperWork(int n, int m)
    {
        //Happy Coding! ^_^
        if(n <=0 || m <=0) return 0;
        return n*m;
    }
    public static int countPassengers(ArrayList<int[]> stops) {
        //Code here!
        int sc = 0;
        int xc = 0;
        for (int[] stop : stops) {
            sc += stop[0];
            xc += stop[1];
        }
        return sc - xc;
    }
    public static void main(String[] args) {
        System.out.println(filterList(Arrays.asList("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","1","1")));
    }
}
